IF OBJECT_ID('TestTableA') IS NOT NULL DROP TABLE TestTableA
IF OBJECT_ID('TestTableB') IS NOT NULL DROP TABLE TestTableB
IF OBJECT_ID('TestView_') IS NOT NULL DROP VIEW TestView_
IF OBJECT_ID('TestView_A') IS NOT NULL DROP VIEW TestView_A
IF OBJECT_ID('TestView_B') IS NOT NULL DROP VIEW TestView_B
GO

CREATE TABLE TestTableA (Id int, ColumnA varchar(50), ColumnB varchar(50))
CREATE TABLE TestTableB (Id int, ColumnA varchar(50), ColumnB varchar(50))
GO

CREATE VIEW TestView_
AS
	SELECT CAST(NULL as VARCHAR(50)) DelegateName, CAST(NULL as int) as Id, CAST(NULL as VARCHAR(50)) as ColumnA, CAST(NULL as VARCHAR(50)) as ColumnB WHERE 1=0
GO

CREATE VIEW TestView_A
AS
	SELECT Id,ColumnA,ColumnB FROM TestTableA
GO

CREATE VIEW TestView_B
AS
	SELECT Id,ColumnA,ColumnB FROM TestTableB
GO

exec qic.Compile
GO

INSERT INTO TestView_ (DelegateName,Id,ColumnA,ColumnB) VALUES ('A',1,'A1','B1')
INSERT INTO TestView_ (DelegateName,Id,ColumnA,ColumnB) VALUES ('A',2,'A2','B2')
INSERT INTO TestView_ (DelegateName,Id,ColumnA,ColumnB) VALUES ('B',3,'A3','B3')
INSERT INTO TestView_ (DelegateName,Id,ColumnA,ColumnB) VALUES ('B',4,'A4','B4')

select * from TestTableA
select * from TestTableB

UPDATE TestView_ SET ColumnA = ColumnB, ColumnB = ColumnA WHERE DelegateName = 'A'
DELETE TestView_ WHERE Id = 3

select * from TestTableA
select * from TestTableB

GO

IF OBJECT_ID('TestTableA') IS NOT NULL DROP TABLE TestTableA
IF OBJECT_ID('TestTableB') IS NOT NULL DROP TABLE TestTableB
IF OBJECT_ID('TestView_') IS NOT NULL DROP VIEW TestView_
IF OBJECT_ID('TestView_A') IS NOT NULL DROP VIEW TestView_A
IF OBJECT_ID('TestView_B') IS NOT NULL DROP VIEW TestView_B
GO